package lq.cloud.studyserversystem.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lq.cloud.studyserversystem.mapper.UserRoleMapper;
import lq.cloud.studyserversystem.service.IUserRoleService;
import lq.common.entity.system.UserRole;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.Arrays;

/**
 * @program: cloud-study
 * @description:
 * @author: LQ
 * @create: 2021-02-03 17:06
 */
@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class IUserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRole> implements IUserRoleService {
    @Override
    public void deleteUserRolesByRoleId(String[] roleIds) {
        Arrays.stream(roleIds).forEach(id->{
            this.baseMapper.deleteByRoleId(Long.valueOf(id));
        });
    }

    @Override
    public void deleteUserRolesByUserId(String[] userIds) {
        Arrays.stream(userIds).forEach(id->{
            this.baseMapper.deleteByUserId(Long.valueOf(id));
        });
    }
}
